
package actions;

import dao.InexistantEntityException;
import entities.Client;
import gestion.GestionnaireRemote;


/**
 * Permet de préparer l'interface de modification du client.
 * @author Alex
 */
public class ModifierClientForm extends MiagetestAction {

    private Integer idClient;

    private String nom;

    private String prenom;

    public Integer getIdClient() {
        return idClient;
    }

    public void setIdClient(Integer idClient) {
        this.idClient = idClient;
    }
    
    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    @Override
    public String execute() {

        GestionnaireRemote gestionnaire = lookupGestionnaireRemote();

        try
        {
            Client client = (Client) gestionnaire.get(Client.class, idClient);
            nom = client.getNom();
            prenom = client.getPrenom();
            setPage("modifierClientForm");
        }
        catch(InexistantEntityException ex)
        {
            setMessage(ex.toString());
        }        

        return SUCCESS;
    }

}
